import matplotlib.pyplot as py
import math
import numpy as np


def myhex(n):
    return "".join(f"0x{n:02x}")


f = open("sin_data.txt", 'w')

size = 1024
y = np.zeros(size)
f.write('{\n')
for x in range(0, size):
    y[x] = round(127 * (math.sin(x / size * 2 * math.pi) + 1)) + 1
    if x < (size - 1):
        f.write(myhex(int(y[x])) + ', ')
    else:
        f.write(myhex(int(y[x])))

    if (x + 1) % 36 == 0:
        f.write('\n')
f.write('}\n')

f.close()

py.plot(y)
py.show()

print(y)
print(len(y))
print(max(y))
print(min(y))
